﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SanctusSoftware.CcliSongSelectLib.Management;
using System.ComponentModel;

namespace SanctusSoftware.CcliSongSelectImporter
{
    public class Settings : INotifyPropertyChanged
    {

        #region Events

        public event PropertyChangedEventHandler PropertyChanged;

        private void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        #endregion

        #region Properties

        private readonly LibraryCollection _Libraries = new LibraryCollection();

        public LibraryCollection Libraries
        {
            get
            {
                return _Libraries;
            }
        }

        private OrganizationInformation _OrganizationInformation = new OrganizationInformation();
        public OrganizationInformation OrganizationInformation
        {
            get { return _OrganizationInformation; }
            set { _OrganizationInformation = value; }
        }

        #endregion

        #region Constructor

        public Settings()
        {
            OrganizationInformation.PropertyChanged += new PropertyChangedEventHandler(OrganizationInformation_PropertyChanged);
        }

        void OrganizationInformation_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            OnPropertyChanged("OrganizationInformation");
        }

        #endregion

        #region Copy

        public static void Copy(Settings source, Settings destination)
        {
            destination.OrganizationInformation.CcliNumber = source.OrganizationInformation.CcliNumber;

            for (int i = 0; i < source.Libraries.Count; i++)
            {
                var sourceLib = source.Libraries[i];
                var destLib = destination.Libraries.FirstOrDefault(item => item.Path == sourceLib.Path);
                if (destLib == null)
                {
                    
                }
            }



        }

        public void CopyTo(Settings destination)
        {
            Copy(this, destination);
        }

        #endregion

    }
}
